package cn.edu.sgu.www.mhxysy.service.qiling.impl;

import cn.edu.sgu.www.mhxysy.entity.qiling.QilingTaozhuangImage;
import cn.edu.sgu.www.mhxysy.mapper.qiling.QilingTaozhuangImageMapper;
import cn.edu.sgu.www.mhxysy.service.qiling.QilingTaozhuangImageService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author 沐雨橙风ιε
 * @version 1.0
 */
@Slf4j
@Service
public class QilingTaozhuangImageServiceImpl implements QilingTaozhuangImageService {

    private final QilingTaozhuangImageMapper qilingTaozhuangImageMapper;

    public QilingTaozhuangImageServiceImpl(QilingTaozhuangImageMapper qilingTaozhuangImageMapper) {
        this.qilingTaozhuangImageMapper = qilingTaozhuangImageMapper;
    }

    @Override
    public QilingTaozhuangImage selectImage(Integer roleId) {
        QueryWrapper<QilingTaozhuangImage> queryWrapper = new QueryWrapper<>();

        queryWrapper.eq("role_id", roleId);
        queryWrapper.last("limit 0, 1");

        return qilingTaozhuangImageMapper.selectOne(queryWrapper);
    }

}